package com.gzhryc.shared_device.oem.code.member.dao.db;

import com.gzhryc.common.NumberTools;
import com.gzhryc.jdbc.annotaion.*;
import com.gzhryc.shared_device.base.enums.ECouponType;
import com.gzhryc.shared_device.base.models.IMemberCoupon;
import com.gzhryc.shared_device.oem.code.business.dao.enums.CouponActivityEnum;
import com.gzhryc.shared_device.oem.code.member.dao.enums.MemberCouponEnum;

import java.util.Date;

@DateBranchTable
@Table(name = "member_coupon")
public class MemberCoupon implements IMemberCoupon {

    @Id
    protected String id;

    @Column(name = "member_id", notNull = true, note = "会员ID")
    protected Long memberId;

    @Column(name = "member_name", note = "会员名称")
    protected String memberName;

    @Column(name = "activity_id", notNull = true,defVal = "0",note = "活动ID，0：代表无关联活动")
    protected Long activityId;

    @Column(name = "coupon_Type", notNull = true, note = "优惠券类型，1:折扣券，2:代金券，3:租期券")
    protected Integer couponType;

    @Column(name = "coupon_money", notNull = true, defVal = "0", note = "优惠金额")
    protected Integer couponMoney;

    @Column(name = "coupon_discount", notNull = true, defVal = "0", note = "优惠折扣")
    protected Double couponDiscount;

    @Column(name = "coupon_day", notNull = true, defVal = "0", note = "优惠天数")
    protected Integer couponDay;

    @Column(name = "minimum_charge", notNull = true, defVal = "0", note = "最低消费金额")
    protected Integer minimumCharge;

    @Column(name = "use_range", notNull = true, defVal = "1", note = "使用范围，1:不限制，2:限定网点")
    protected Integer useRange;

    @Column(name = "place_id", note = "网点ID")
    protected Long placeId;

    @Column(name = "place_name", note = "网点名称")
    protected String placeName;

    @Column(name = "use_limit", notNull = true, defVal = "1", note = "限制类型，1:不限制，2:限制业务类型")
    protected Integer useLimit;

    @Column(name = "business_type", note = "业务类型")
    protected String businessType;

    @Column(length = 64, note = "优惠券描述")
    protected String note;

    @Column(name = "expiration_date", notNull = true, note = "到期时间")
    protected Date expirationDate;

    @Column(name = "use_trade_no", note = "使用订单")
    protected String useTradeNo;

    @Column(name = "use_date", note = "使用时间")
    protected Date useDate;

    @Column(notNull = true, defVal = "1", note = "优惠券状态")
    protected Integer state;

    @Column(name = "update_date", autoUpdateTime = true)
    protected Date updateDate;

    @Column(name = "create_date")
    protected Date createDate;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }

    public Long getActivityId() {
        return activityId;
    }

    public void setActivityId(Long activityId) {
        this.activityId = activityId;
    }

    public Integer getCouponType() {
        return couponType;
    }

    public void setCouponType(Integer couponType) {
        this.couponType = couponType;
    }

    public Integer getCouponMoney() {
        return couponMoney;
    }

    public void setCouponMoney(Integer couponMoney) {
        this.couponMoney = couponMoney;
    }

    public Integer getMinimumCharge() {
        return minimumCharge;
    }

    public void setMinimumCharge(Integer minimumCharge) {
        this.minimumCharge = minimumCharge;
    }

    public Double getCouponDiscount() {
        return couponDiscount;
    }

    public void setCouponDiscount(Double couponDiscount) {
        this.couponDiscount = couponDiscount;
    }

    public Integer getCouponDay() {
        return couponDay;
    }

    public void setCouponDay(Integer couponDay) {
        this.couponDay = couponDay;
    }

    public Integer getUseRange() {
        return useRange;
    }

    public void setUseRange(Integer useRange) {
        this.useRange = useRange;
    }

    public Long getPlaceId() {
        return placeId;
    }

    public void setPlaceId(Long placeId) {
        this.placeId = placeId;
    }

    public String getPlaceName() {
        return placeName;
    }

    public void setPlaceName(String placeName) {
        this.placeName = placeName;
    }

    public Integer getUseLimit() {
        return useLimit;
    }

    public void setUseLimit(Integer useLimit) {
        this.useLimit = useLimit;
    }

    public String getBusinessType() {
        return businessType;
    }

    public void setBusinessType(String businessType) {
        this.businessType = businessType;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public Date getExpirationDate() {
        return expirationDate;
    }

    public void setExpirationDate(Date expirationDate) {
        this.expirationDate = expirationDate;
    }

    public String getUseTradeNo() {
        return useTradeNo;
    }

    public void setUseTradeNo(String useTradeNo) {
        this.useTradeNo = useTradeNo;
    }

    public Date getUseDate() {
        return useDate;
    }

    public void setUseDate(Date useDate) {
        this.useDate = useDate;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getCouponTypeName(){
        return ECouponType.note(this.couponType);
    };

    public String getStateName() {
        return MemberCouponEnum.State.note(this.state);
    }

    public String getUseRangeName() {
        return CouponActivityEnum.UseRange.note(this.useRange);
    }

    public String getUseLimitName() {
        return CouponActivityEnum.UseLimit.note(this.useLimit);
    }

    public String getCouponMoneyStr(){
        return NumberTools.getMoneyStr(this.couponMoney);
    }

    public String getMinimumChargeStr(){
        return NumberTools.getMoneyStr(this.minimumCharge);
    }

    public String getTitle() {
        if (ECouponType.VOUCHERS.index().equals(this.couponType)) {
            //代金券
            if (this.minimumCharge > 0) {
                return "满" + NumberTools.getMoneyStr(this.minimumCharge) + "元立减" + NumberTools.getMoneyStr(this.couponMoney) + "元优惠券";
            } else {
                return "消费立减" + NumberTools.getMoneyStr(this.couponMoney) + "元优惠券";
            }
        }else if(ECouponType.DISCOUNT_COUPON.index().equals(this.couponType)) {
            //折扣券
            if (this.minimumCharge > 0) {
                return "满" + NumberTools.getMoneyStr(this.minimumCharge) + "元打" + this.couponDiscount + "折优惠券";
            } else {
                return "消费打" + this.couponDiscount + "折优惠券";
            }
        }else if(ECouponType.COUPON_DAY.index().equals(this.couponType)) {
            return "免费" + this.couponDay + "天租金";
        }else{
            return "无优惠";
        }
    }
}
